<template>
  <div>
    <el-table
      :data="list"
      style="width: 100%"
      row-key="id"
      border
      :tree-props="{children: 'children'}"
    >
      <el-table-column prop="id" label="用户编号" width="180"></el-table-column>
      <el-table-column prop="username" label="用户名称"></el-table-column>
      <el-table-column prop="rolename" label="所属角色"></el-table-column>
      <el-table-column label="状态">
        <template slot-scope="scope">
          <el-button type="primary" v-if="scope.row.status==1">启用</el-button>
          <el-button type="info" v-else>禁用</el-button>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="primary" @click="willEdit(scope.row.uid)">编辑</el-button>
          <el-button type="denger" @click="del(scope.row.uid)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import {successAlert} from "../../../utils/alert";
import { mapGetters, mapActions } from "vuex";
import { requserdelete } from "../../../request/api";
export default {
  components: {},
  computed: {
    ...mapGetters({}),
  },
  methods: {
    //将要编辑
    willEdit(uid) {
      this.$emit("edit", uid);
    },
    //将要删除
    del(uid) {
      requserdelete({ uid: uid }).then((res) => {
        if (res.data.code == 200) {
          //弹框
          successAlert(res.data.msg);
          //刷新
          this.$emit("init");
        }
      });
    },
  },
  mounted() {},
  props: ["list"],
  data() {
    return {
      tableData: [],
    };
  },
};
</script>
<style lang="less">
</style>